package com.kedacom.demo.rabbitmq_java_client.ch4.routing;

import java.util.concurrent.TimeoutException;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

public class EmitLog {

	public static void main(String[] args) throws java.io.IOException, TimeoutException {
		ConnectionFactory factory = new ConnectionFactory();
		factory.setHost(Constants.RABBITMQ_HOST);
		Connection connection = factory.newConnection();
		Channel channel = connection.createChannel();

		channel.exchangeDeclare(Constants.EXCHANGE_NAME, "direct");

		String message = "this is an warning message.";
		channel.basicPublish(Constants.EXCHANGE_NAME, Constants.SEVERITY_WARNING, null, message.getBytes());
		System.out.println(" [x] Sent '" + message + "'");
		message = "this is an info message.";
		channel.basicPublish(Constants.EXCHANGE_NAME, Constants.SEVERITY_INFO, null, message.getBytes());
		System.out.println(" [x] Sent '" + message + "'");
		message = "this is an error message.";
		channel.basicPublish(Constants.EXCHANGE_NAME, Constants.SEVERITY_ERROR, null, message.getBytes());
		System.out.println(" [x] Sent '" + message + "'");

		channel.close();
		connection.close();
	}

}
